package form;

abstract public class FormElement extends FormNode
{
	String body;
	
	public void setBody(String body)
	{
		this.body = body;
	}
	
	public String getBody()
	{
		return body;
	}
	
	public String getElementCode()
	{
		String code;
		
		if (isShortTag())
		{
			code = ('<' + getTagName() + getAttributesCode() + " />");
		}
		else
		{
			code = ('<' + getTagName() + getAttributesCode() + '>');
			
			if (body != null)
			{
				code += body;
			}
			
			code += ("</" + getTagName() + '>');
		}
		
		return code;
	}
	
	@Override
	public String getCode()
	{
		return "<div class=\"form-element\">" + getElementCode() + "</div>";
	}
}
